<template>
  <div class="address">
    <!-- 导航栏  新增地址-->
    <div class="tou">新增地址</div>

    <van-address-edit
      :area-list="areaList"
      show-postal
      show-delete
      show-set-default
      show-search-result
      :area-columns-placeholder="['请选择', '请选择', '请选择']"
      @save="onSave"
      @delete="onDelete"
      @change-detail="onChangeDetail"
    />
  </div>
</template>

<script>
import { Toast } from "vant";
// import { areaList } from '@vant/area-data';

export default {
  data() {
    return {
      areaList: {
        province_list: {
          110000: "北京市",
          120000: "天津市"
        },
        city_list: {
          110100: "北京市",
          120100: "天津市"
        },
        county_list: {
          110101: "东城区",
          110102: "西城区"
          // ....
        }
      }
    };
    // return { areaList };
  },
  methods: {
    onSave(val) {
      console.log(val);
      Toast("save");
    },
    onDelete() {
      Toast("delete");
    },
    onChangeDetail(val) {
      if (val) {
        this.searchResult = [
          {
            name: "黄龙万科中心",
            address: "杭州市西湖区"
          }
        ];
      } else {
        this.searchResult = [];
      }
    }
  }
};
</script>

<style scoped>
/* ================ 头部 =============== */
.van-nav-bar {
  width: 100%;
  background-image: linear-gradient(
      180deg,
      #fe502d 0%,
      #fb4723 31%,
      #fb5136 71%,
      #ff5849 100%
    ),
    linear-gradient(#fff3f2, #fff3f2);
}
.tou {
  width: 100%;
  background-color: #fb4723;

  height: 46px;
  color: #323233;

  font-size: 24px;

  display: flex;
  justify-content: center; /* 水平居中 */
  align-items: center; /* 垂直居中 */
}
</style>